var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(e, d, c) {
    if (status == 0 && e == 0) {
        im.dispose();
        return
    }(e == 1) ? status++ : status--;
    selectionLog[status] = c;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            im.dispose();
            var f = im.getItemId();
            im.gainItem(f, -1);
            var b = im.rand(1, 100);
            if (b < 15) {
                im.gainItem(2614026, 1)
            } else {
                if (b < 15 + 30) {
                    im.gainItem(2614049, 1)
                } else {
                    im.gainItem(2614053, 1)
                }
            }
        }
    }
};